﻿package birdry.utils	{
	import flash.geom.Point;
	
	//	birdry.utils.MathUtil;
	
	
	public class PointUtil	{
		
		public static function radiusToPoint( radius:Number, total:int = 12, position:int = 0, order:int = 0):Point  {   
			var divisionRadian:Number = 2 * Math.PI / total;
			var point:Point = new Point();
			point.x = radius * Math.sin(divisionRadian *  (position-order));
			point.y = radius * Math.cos(divisionRadian * (position-order));
			return point;
		}
		/*
		circleArray[i].x = radiusX * Math.sin(divisionRadian * ((order + startNum) - position));
		circleArray[i].y = radiusY * Math.cos(divisionRadian * ((order + startNum) - position));
		*/
				
		public static function repulseDelta(originPoint:Point, currentPoint:Point, crashPoint:Point, xK:uint = 100000, yK:uint = 100000): Point	{
			var diffX:Number = currentPoint.x - crashPoint.x;
			var diffY:Number = currentPoint.y - crashPoint.y;
			var r:Number = Math.sqrt(diffX * diffX + diffY * diffY);
			var targetPoint:Point = new Point(	
															(xK / (r * r * r) * diffX) + originPoint.x,
															(yK / (r * r * r) * diffY) + originPoint.y
														);
			return targetPoint;
		}
		
	}	// class
}	// package